package com.wx.mall.operate.feign;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wx.mall.operate.entity.DisUse;
import com.wx.mall.operate.service.IDisUseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/disUseFeign")
@Api(tags = "优惠券用户关联表",description = "DisUserFeign")
@Slf4j
public class DisUserFeign {

    @Autowired
    private IDisUseService service;

    @ApiOperation("根据用户id查询出各项记录数")
    @GetMapping("/getTotal")
    public Map<String,Integer> getTotal(Long useId){


int count=service.count(new QueryWrapper<DisUse>().eq("use_id",useId).eq("state",0));
int countTwo=service.count(new QueryWrapper<DisUse>().eq("use_id",useId).eq("state",1));
int countThree=service.count(new QueryWrapper<DisUse>().eq("use_id",useId).eq("state",2));

Map<String,Integer> map=new HashMap<String, Integer>();
map.put("notState",count);
map.put("useState",countTwo);
map.put("timeOut",countTwo);

return map;

    }
}
